﻿using BLL.Comm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Inventory.template
{
    public partial class BaseInfoForm : Form
    {
        public Operation opera;
        public BaseInfoForm()
        {
            InitializeComponent();//定义操作类型变量
            opera = Operation.NONE;//默认操作为NONE(不可操作）
            gbBase.Visible = false;//默认groubox隐藏
        }

        private void tagbtnXz_Click(object sender, EventArgs e)
        {
            opera = Operation.INSERT;
            ClickEven("新增");
        }

        private void tagbtnXg_Click(object sender, EventArgs e)
        {
            opera = Operation.UPDATE ;
            ClickEven("修改");
        }

        private void tagbtnSc_Click(object sender, EventArgs e)
        {
            opera = Operation.DELETE ;
            ClickEven("删除");
        }/// <summary>
         /// 处理单击事件窗口可见性方法
         /// </summary>
         /// <param name="opera"></param>
        private void ClickEven(string  opera=null)
        {
            if (opera ==null ||opera == "")
            {
                tagbtnXz.Enabled = tagbtnXg.Enabled = tagbtnSc.Enabled  = true;//默认：新增、修改、删除按钮为可见
                gbBase.Visible = false;//groupbox控件可见性为false
            }
            else
            {
                tagbtnXz.Enabled = tagbtnXg.Enabled = tagbtnSc.Enabled = false ;//默认：新增、修改、删除按钮为不可见
                gbBase.Visible = true;//groupbox控件可见性为false
                gbBase.Text = opera + "处理";
            }
        }

        private void tagbtnQx_Click(object sender, EventArgs e)
        {
            opera = Operation.NONE ;
            ClickEven();
            Clear();
        }
        ///可继承方法
        ///清空文本框
        ///
        protected void Clear()
        {
            foreach (Control item in gbBase.Controls)
                if (item is TextBox)
                    item.Text = "";
        }

        private void gbBase_Enter(object sender, EventArgs e)
        {

        }
    }
}
